Presence-absence data

Author

Florencia Grattarola

Published

September 11, 2024

Code
library(plotly)
library(packcircles)
library(ggiraph)
library(countrycode)
library(tmap)
tmap_mode('view')
library(sf)
sf::sf_use_s2(FALSE)
library(tidyverse)

Data

List of species

carnivores <- read_csv('data/carnivores.csv')

Number of carnivore species in the Neotropics = 71

Countries

countries <- st_read('data/latam.gpkg', layer = 'countries', quiet = T)

Number of countries in the Neotropics = 21

Presence only records

PA <- read_csv('data/data_PA.csv')

data_PA <- PA %>% 
  st_as_sf(coords=c('decimalLongitude', 'decimalLatitude')) %>%
  st_set_crs(4326)

Number of PA records of presences (= 1) = 25998
Number of PA records of absences (= 0) = 19470
Number of species represented in the PA data = 50 (70.4 %)

Sources

Top 10 data sources (dataset names)

Code
PA %>% 
  count(datasetName, dataSource) %>% 
  arrange(desc(n)) %>% filter(!is.na(datasetName)) %>% 
  slice_head(n=10) %>% 
  rename(`Dataset name`= datasetName, 
         `Data source` = dataSource) %>% 
  mutate(`%` = formattable::percent(n / sum(n))) %>% 
  kableExtra::kbl()
Dataset name Data source n %
Are tree plantations promoting homogenization of mammal assemblages between regions with contrasting environments? literature 6120 26.96%
Oncafari data paper 3333 14.68%
Hufnagel,Ludmila_LEC-QF data paper 2915 12.84%
IgorPfeiferCoelho data paper 2880 12.68%
WCS-Bolivia data paper 2005 8.83%
Equipe_SC data paper 1447 6.37%
Tick-tock… says the moon and the sun: Daily activity patterns of mid-large-sized mammals in grassland-dominated landscapes afforested with Eucalyptus literature 1040 4.58%
Santiago Espinosa data paper 1034 4.55%
Cronemberger_Parnaso data paper 1032 4.55%
Selecao Natural data paper 898 3.96%

Number of datasets involved in the PA data = 271
Number of datasets involved in the PA data from the literature = 64
Number of datasets involved in the PA data from the data paper = 207

Geographic coverage

Data are summarised per camera trap study (datasetName)

Code
tmap_mode('view')
data_PA %>% 
  group_by(datasetName) %>% 
  summarise(country = first(country), 
            eventDurationValue = first(eventDurationValue),
            eventDurationUnit = first(eventDurationUnit),
            samplingEffortValue = first(samplingEffortValue),
            samplingEffortUnit = first(samplingEffortUnit),
            totalAreaSampledValue = first(totalAreaSampledValue),
            totalAreaSampledUnit = first(totalAreaSampledUnit),
            dataSource = first(dataSource),
            n_species=n_distinct(scientificName)) %>% st_cast('POINT') %>% 
  tm_shape() +
    tm_dots(size = 0.25) + 
    tm_shape(countries) +
    tm_borders(col='grey60', alpha = 0.2) +
    tm_layout(asp = 0, legend.outside= T, legend.outside.size = 0.1)
Code
PA %>% 
    group_by(country) %>%
    summarise(`Number of records`= n(),
              `presences`= sum(presence==1), 
              `absences`= sum(presence==0), 
              `Number of species`= n_distinct(scientificName)) %>% 
  mutate(code=countrycode(country,
                          origin = 'country.name',
                          destination = 'iso2c')) %>%
  relocate(country, code) %>% 
  kableExtra::kbl()
country code Number of records presences absences Number of species
Argentina AR 7373 1365 6008 22
Belize BZ 5 5 0 5
Bolivia BO 1858 1858 0 22
Brazil BR 27563 17341 10222 27
Chile CL 23 23 0 7
Colombia CO 549 405 144 17
Costa Rica CR 739 306 433 22
Ecuador EC 1469 751 718 20
Guatemala GT 642 642 0 12
Guyana GY 28 22 6 8
Honduras HN 11 5 6 11
Mexico MX 1075 1049 26 23
Panama PA 36 26 10 15
Paraguay PY 117 114 3 15
Peru PE 1401 937 464 25
Suriname SR 970 200 770 15
Uruguay UY 1494 834 660 12
Venezuela VE 115 115 0 8

Number of countries represented in the PA data = 18

Taxonomic coverage

Considering only the presences.

Code
data <- PA %>% filter(presence==1) %>% 
  group_by(family) %>% 
  summarise(n_records=n(), n_species=n_distinct(scientificName)) 

packing <- circleProgressiveLayout(data$n_records, sizetype='area')
data <- cbind(data, packing)
packing$radius <- 0.95*packing$radius

dat.gg <- circleLayoutVertices(packing, npoints=50)
data$text <- paste('family: ', data$family, 
                   '\n', 'records:', data$n_records, 
                   '\n', 'species:', data$n_species)

plot.gg <- ggplot() + 
  geom_polygon_interactive(data = dat.gg,
                           aes(x, y, group = id, fill=id,
                               tooltip = data$text[id],
                               data_id = id), colour = 'black', alpha = 0.6) +
  scale_fill_continuous_interactive(type = 'viridis') +
  geom_text(data = data, aes(x, y, label = gsub('Group_', '', family)), size=3, color='black') +
  theme_void() + 
  theme(legend.position='none', plot.margin=unit(c(0,0,0,0),'cm') ) + 
  coord_equal()

x <- girafe(ggobj = plot.gg)
x
Code
PA %>%
  group_by(scientificName, family) %>% count(presence) %>% 
  mutate(presence = if_else(presence == 1, 'presence', 'absence')) %>% 
  pivot_wider(names_from = presence, 
              values_from = n, values_fill = 0) %>% 
  rename(`Number of absences`= absence,
         `Number of presences`= presence,) %>% 
  kableExtra::kbl()
scientificName family Number of absences Number of presences
Atelocynus microtis Canidae 207 290
Bassaricyon alleni Procyonidae 0 1
Bassariscus astutus Procyonidae 0 40
Bassariscus sumichrasti Procyonidae 15 1
Canis latrans Canidae 50 89
Cerdocyon thous Canidae 1261 4065
Chrysocyon brachyurus Canidae 1046 480
Conepatus chinga Mephitidae 631 189
Conepatus leuconotus Mephitidae 0 71
Conepatus semistriatus Mephitidae 361 380
Eira barbara Mustelidae 1477 2223
Galictis cuja Mustelidae 267 101
Galictis vittata Mustelidae 126 44
Herpailurus yagouaroundi Felidae 1622 787
Leopardus colocola Felidae 3 1
Leopardus geoffroyi Felidae 601 249
Leopardus guigna Felidae 0 6
Leopardus guttulus Felidae 702 742
Leopardus jacobita Felidae 0 11
Leopardus pardalis Felidae 1298 4242
Leopardus tigrinus Felidae 506 224
Leopardus wiedii Felidae 1306 918
Lontra longicaudis Mustelidae 467 86
Lontra provocax Mustelidae 0 1
Lycalopex culpaeus Canidae 0 41
Lycalopex grisea Canidae 1 11
Lycalopex gymnocerca Canidae 411 508
Lycalopex sechurae Canidae 0 34
Lycalopex vetula Canidae 209 127
Lyncodon patagonicus Mustelidae 0 3
Lynx rufus Felidae 2 56
Mephitis macroura Mephitidae 2 28
Nasua narica Procyonidae 22 303
Nasua nasua Procyonidae 1298 2908
Nasua olivacea Procyonidae 16 3
Neogale africana Mustelidae 1 1
Neogale frenata Mustelidae 17 26
Panthera onca Felidae 1410 2074
Potos flavus Procyonidae 31 17
Procyon cancrivorus Procyonidae 1611 1661
Procyon lotor Procyonidae 38 120
Pteronura brasiliensis Mustelidae 273 22
Puma concolor Felidae 1602 2478
Speothos venaticus Canidae 566 64
Spilogale angustifrons Mephitidae 0 6
Spilogale gracilis Mephitidae 0 11
Spilogale pygmaea Mephitidae 2 3
Tremarctos ornatus Ursidae 8 26
Urocyon cinereoargenteus Canidae 4 204
Ursus americanus Ursidae 0 22

Species not covered

Code
# species not included  
carnivores %>% 
  filter(!species %in% unique(PA$scientificName)) %>%
  select(species, family) %>% arrange(family, species) %>% 
  kableExtra::kbl()
species family
Canis lupus Canidae
Lycalopex fulvipes Canidae
Vulpes macrotis Canidae
Leopardus braccatus Felidae
Leopardus emiliae Felidae
Leopardus fasciatus Felidae
Leopardus garleppi Felidae
Leopardus narinensis Felidae
Leopardus pajeros Felidae
Mephitis mephitis Mephitidae
Spilogale interrupta Mephitidae
Spilogale leucoparia Mephitidae
Spilogale yucatanensis Mephitidae
Enhydra lutris Mustelidae
Lontra canadensis Mustelidae
Neogale felipei Mustelidae
Taxidea taxus Mustelidae
Bassaricyon gabbii Procyonidae
Bassaricyon medius Procyonidae
Bassaricyon neblina Procyonidae
Procyon pygmaeus Procyonidae

Temporal coverage

Code
coef <- 150

plot_records <- ggplot(PA, aes(x = dateStart, y = scientificName, colour = scientificName)) +
  geom_segment(aes(xend = dateEnd, yend = scientificName), colour = 'black') +
  geom_point(size = 3) +
  geom_point(aes(x = dateEnd), size = 3) +
  theme_bw() +
  theme(legend.position = 'none') +
  labs(x='', y='')

plot_records <- ggplotly(plot_records)
plot_records